import torch
import torch.nn as nn

# 定义解码器
decoder = nn.Sequential(
    nn.ConvTranspose3d(256, 128, kernel_size=(3, 6, 6), stride=(1, 2, 2), padding=(1, 2, 2)),
    nn.BatchNorm3d(128),
    nn.LeakyReLU(),
    nn.ConvTranspose3d(128, 64, kernel_size=(3, 6, 6), stride=(1, 2, 2), padding=(1, 2, 2)),
    nn.BatchNorm3d(64),
    nn.LeakyReLU(),
    nn.ConvTranspose3d(64, 1, kernel_size=1, stride=1, padding=0),
    nn.Sigmoid()
)

# 假设中间层的输出为 [4, 256, 20, 120, 140]
input_tensor = torch.randn(4, 256, 20, 120, 140)

# 计算每一层的输出形状
output1 = decoder[0](input_tensor)  # 第一层 ConvTranspose3d
output2 = decoder[3](output1)  # 第二层 ConvTranspose3d
output3 = decoder[6](output2)  # 第三层 ConvTranspose3d

print("第一层输出形状:", output1.shape)
print("第二层输出形状:", output2.shape)
print("第三层输出形状:", output3.shape)